import os
import warnings

import yaml
from pandas.errors import DtypeWarning
from xbase_util.common_util import get_project_root
from xbase_util.db.initsqlite3 import initSqlite3
from xbase_util.esreq import EsReq
from xbase_util.geo_util import GeoUtil

warnings.filterwarnings('ignore', category=DtypeWarning)
warnings.filterwarnings('ignore', category=RuntimeWarning)
project_path = get_project_root("xcapture")
out_folder = os.path.join(project_path, "out")

config_types = [
    "session",
    "pcap",
    "extract_pcap",
    "label",
    "replace"
]
config_file = open(os.path.join(project_path, "config.yaml"), "r")
global_base_config = yaml.safe_load(config_file)
config_file.close()
global_geoutil = GeoUtil()
req = EsReq(global_base_config["es_url"])
flowDao, configDao, currentConfigDao, taskTemplateDao = initSqlite3(
    f'sqlite:///{os.path.join(project_path, "sqlite3.db")}')